home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 3.6 KB | 98 lines | [TEXT/MPS ] |
- // UDialogBehavior.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDIALOGBEHAVIOR__
- #define __UDIALOGBEHAVIOR__
-
- // MacApp
-
- #ifndef __UBEHAVIOR__
- #include "UBehavior.h"
- #endif
-
- const IDType kDialogBehavior = 'dlog'; // id of dialog behaviors
- const IDType kStdDialogBehavior = 'dlgb'; // class id of dialog behaviors
-
- //----------------------------------------------------------------------------------------
- // TDialogBehavior
- //
- // When installed in a window, this behavior handles events appropriately for both modal
- // and modeless dialogs. One subview can be designated the "default item" (eg. OK button)
- // and another the "cancel item" (eg. Cancel button in a modal dialog). Pressing the OK
- // button in a modal dialog causes the window to be validated. This behavior also treats the
- // pressing of the Enter and Return keys as a click in the default item, and Esc and
- // Command-Period as a click in the cancel item.
- //
- // TWindow.PoseModally calls this behavior's PoseModally method to place the window in
- // a modal state.
- //----------------------------------------------------------------------------------------
-
- class TDialogBehavior : public TBehavior
- {
- MA_DECLARE_CLASS;
-
- public:
- //------------------------------------------------------------------------------------
- // Initializer and I<Method>.
- //------------------------------------------------------------------------------------
-
- TDialogBehavior();
- // Constructor
- virtual ~TDialogBehavior();
- // Destructor
-
- void IDialogBehavior(Boolean isModal,
- IDType itsDefaultItem,
- IDType itsCancelItem);
- // Initialize this behavior procedurally.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFrom(TStream* aStream);
-
- virtual void WriteTo(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Event handling.
- //------------------------------------------------------------------------------------
-
- virtual void Dismiss(IDType dismisser, Boolean validate);
- // Dismiss the owning view (window), validating if requested.
-
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event); // Override
- // Handles the mDefaultKey and mCancelKey events. Translates events from
- // the default and cancel items into these events.
-
- virtual void DoKeyEvent(TToolboxEvent* event); // Override
- // Handles the Enter and Return keys.
-
- virtual void DoCommandKeyEvent(TToolboxEvent* event); // Override
- // Handles the Esc key and Command-Period.
-
- virtual void PoseModally();
- // Places the window owning this behavior in a modal state.
- // Processes events until fDismissed is true.
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- IDType fDefaultItem; // The identifier of the view designated as default item
- IDType fCancelItem; // The identifier of the view designated as cancel item
- // Usually the cancel button in a modal dialog, and
- // kNoIdentifier for a modeless dialog.
- IDType fDismisser; // The identifier of the item which dismissed a modal dialog
- Boolean fModal; // True if modal behavior is required
- Boolean fDismissed; // Becomes true when a modal dialog is dismissed.
-
- };
-
- #endif
-